package com.tang.crm.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tang.crm.dto.OrderDetailsDto;
import com.tang.crm.entity.OrderDetails;
import com.tang.crm.entity.Role;
import com.tang.crm.mapper.OrderDetailsMapper;
import com.tang.crm.service.OrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements OrderDetailsService {

    @Autowired
    private OrderDetailsMapper orderDetailsMapper;

    /**
     * 分页条件查询订单详情列表
     * @param orderDetailsDto
     * @return
     */
    @Override
    public Map<String, Object> selectByParams(OrderDetailsDto orderDetailsDto) {
        Map<String, Object> map = new HashMap<>();
        Page<OrderDetails> pageInfo = new Page<>(orderDetailsDto.getPage(), orderDetailsDto.getLimit());
        IPage<Map<String, Object>> mapIPage = orderDetailsMapper.selectByParams(pageInfo, orderDetailsDto);
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", mapIPage.getTotal());
        map.put("data", mapIPage.getRecords());
        return map;
    }
}
